<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    

<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="keywords" content="汽车租赁管理系统, Zhou•Yong">
    <meta name="description" content="汽车租赁管理系统一个小demo写的蛮简单，主要练习用，写了2个版本，一个是把数据存到数据库的版本，一个把数据存到本地文件的版本
数据存到本地文件的版本核心代码using System;
using System.Collections.Ge">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>汽车租赁管理系统 | Zhou•Yong</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/css/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>

</head>

<body>

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="container">
            <div class="nav-wrapper">
                <div class="brand-logo">
                    <a href="/" class="waves-effect waves-light">
                        
                        <img src="/medias/logo.png" class="logo-img hide-on-small-only">
                        
                        <span class="logo-span">Zhou•Yong</span>
                    </a>
                </div>
                <a href="#" data-activates="mobile-nav" class="button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>主页</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>个人介绍</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>分类</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>标签</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/friends" class="waves-effect waves-light">
            
            <i class="fa fa-address-book"></i>
            
            <span>推荐</span>
        </a>
    </li>
    
    <li>
        <a id="toggleSearch" class="waves-effect waves-light">
            <i id="searchIcon" class="mdi-action-search"></i>
        </a>
    </li>

</ul>

<div class="side-nav" id="mobile-nav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">Zhou•Yong</div>
        <div class="logo-desc">
            
            你迈出的步伐不非得很大，只要你是在正确的方向前进就行
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                主页
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                个人介绍
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                分类
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                标签
            </a>
        </li>
        
        <li>
            <a href="/friends" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-address-book"></i>
                
                推荐
            </a>
        </li>
        
        
    </ul>

    <div class="social-link"><a href="#!" class="tooltipped" data-tooltip="邮件联系我: zy20081@126.com" data-position="top" data-delay="50">
    <i class="fa fa-envelope-open"></i>
</a>
<a href="#!" class="tooltipped" data-tooltip="QQ联系我: 314153271" data-position="top" data-delay="50">
    <i class="fa fa-qq"></i>
</a>

<a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
    <i class="fa fa-rss"></i>
</a>
</div>
</div>

            </div>
        </div>

        
    </nav>
</header>





<div class="bg-cover post-cover" style="background-image: url('/medias/featureimages/4.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        汽车租赁管理系统
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1,
    #articleContent h2,
    #articleContent h3,
    #articleContent h4,
    #articleContent h5,
    #articleContent h6 {
        padding-top: 76px;
        margin-top: -76px;
    }

    #articleContent h1 {
        line-height: 3.5rem;
    }

    #articleContent h2 {
        line-height: 3.2rem;
    }

    #articleContent h3 {
        line-height: 2.8rem;
    }

    #articleContent h4 {
        line-height: 2.5rem;
    }

    #articleContent h5 {
        line-height: 2.2rem;
    }

    #articleContent h6 {
        line-height: 1.9rem;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }
</style>
<div class="row">
    <div class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            
            <div class="article-tag">
                
                <a href="/tags/ASP-NET/" target="_blank">
                    <span class="chip bg-color">ASP.NET</span>
                </a>
                
                <a href="/tags/C-Demo/" target="_blank">
                    <span class="chip bg-color">C# Demo</span>
                </a>
                
            </div>
            
            <div class="post-info">
                
                <span class="post-cate">
                    <i class="fa fa-bookmark fa-fw icon-category"></i>
                    
                    <a href="/categories/ASP-NET/" class="post-category" target="_blank">
                        ASP.NET
                    </a>
                    
                </span>
                

                <span class="post-date">
                    <i class="fa fa-clock-o fa-fw"></i>2019-01-11
                </span>
            </div>
        </div>
        <hr>
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="汽车租赁管理系统"><a href="#汽车租赁管理系统" class="headerlink" title="汽车租赁管理系统"></a>汽车租赁管理系统</h2><p>一个小demo写的蛮简单，主要练习用，写了2个版本，一个是把数据存到数据库的版本，一个把数据存到本地文件的版本<br><img src="/2019/01/11/qi-che-zu-ren-guan-li-xi-tong/1.jpg" alt="图1"><br><img src="/2019/01/11/qi-che-zu-ren-guan-li-xi-tong/2.jpg" alt="图2"><br><img src="/2019/01/11/qi-che-zu-ren-guan-li-xi-tong/3.jpg" alt="图3"><br><img src="/2019/01/11/qi-che-zu-ren-guan-li-xi-tong/4.jpg" alt="图4"></p>
<h2 id="数据存到本地文件的版本核心代码"><a href="#数据存到本地文件的版本核心代码" class="headerlink" title="数据存到本地文件的版本核心代码"></a>数据存到本地文件的版本核心代码</h2><pre class=" language-bash"><code class="language-bash">using System<span class="token punctuation">;</span>
using System.Collections.Generic<span class="token punctuation">;</span>
using System.ComponentModel<span class="token punctuation">;</span>
using System.Data<span class="token punctuation">;</span>
using System.Drawing<span class="token punctuation">;</span>
using System.Linq<span class="token punctuation">;</span>
using System.Text<span class="token punctuation">;</span>
using System.Windows.Forms<span class="token punctuation">;</span>
using System.Collections<span class="token punctuation">;</span>
using System.IO<span class="token punctuation">;</span>
using System.Runtime.Serialization.Formatters.Binary<span class="token punctuation">;</span>
namespace Car
<span class="token punctuation">{</span>
    public partial class Form1 <span class="token keyword">:</span> Form
    <span class="token punctuation">{</span>

        TrafficInfo tNew<span class="token punctuation">;</span>//父类
        XRentManager m_RM <span class="token operator">=</span> new XRentManager<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//实例化一个管理类对象
        public Form1<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            InitializeComponent<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        private void btnAdd_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            TraMessage<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//入库信息

        <span class="token punctuation">}</span>
        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 入库信息
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        public void TraMessage<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token comment" spellcheck="true">#region 为空判断</span>

            Dictionary<span class="token operator">&lt;</span>string, string<span class="token operator">></span> dicTracffic <span class="token operator">=</span> new Dictionary<span class="token operator">&lt;</span>string, string<span class="token operator">></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"车牌号"</span>, txtNumber.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"车名"</span>, txtName.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"车颜色"</span>, cbColor.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"使用时间"</span>, txtTime.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"租金"</span>, txtMoney.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"载重量"</span>, txtLoad.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>string str <span class="token keyword">in</span> dicTracffic.Keys<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>dicTracffic<span class="token punctuation">[</span>str<span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">""</span><span class="token punctuation">)</span> //str就是K,dicTracffic<span class="token punctuation">[</span>str<span class="token punctuation">]</span>就是值
                <span class="token punctuation">{</span>
                    MessageBox.Show<span class="token punctuation">(</span>string.Format<span class="token punctuation">(</span><span class="token string">"请输入{0}"</span>, str<span class="token punctuation">))</span><span class="token punctuation">;</span>

                    <span class="token keyword">return</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
            <span class="token comment" spellcheck="true">#endregion</span>

            <span class="token keyword">if</span> <span class="token punctuation">(</span>rdoCar.Checked <span class="token operator">==</span> true<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                tNew <span class="token operator">=</span> new Xcar<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//创立对象
            <span class="token punctuation">}</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>rdoTruck.Checked <span class="token operator">==</span> true<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                tNew <span class="token operator">=</span> new XTruck<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>


            <span class="token punctuation">}</span>
            tNew.Number <span class="token operator">=</span> txtNumber.Text<span class="token punctuation">;</span>//车牌号码
            tNew.Name <span class="token operator">=</span> txtName.Text<span class="token punctuation">;</span>//车名
            tNew.Color <span class="token operator">=</span> cbColor.Text<span class="token punctuation">;</span>//车颜色
            tNew.Time <span class="token operator">=</span> txtTime.Text<span class="token punctuation">;</span>//使用时间
            tNew.Money <span class="token operator">=</span> int.Parse<span class="token punctuation">(</span>txtMoney.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>//租金
            tNew.Load <span class="token operator">=</span> txtLoad.Text<span class="token punctuation">;</span>//载重

            try
            <span class="token punctuation">{</span>
                m_RM.InputLibry<span class="token punctuation">(</span>tNew<span class="token punctuation">)</span><span class="token punctuation">;</span>//可以出租的车集合
            <span class="token punctuation">}</span>
            catch <span class="token punctuation">(</span>Exception ex<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>

                MessageBox.Show<span class="token punctuation">(</span>ex.Message<span class="token punctuation">)</span><span class="token punctuation">;</span>
                txtNumber.Text <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
                txtNumber.Focus<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">return</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            addTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            this.tabControl1.SelectedTab <span class="token operator">=</span> tpRent<span class="token punctuation">;</span>
            MessageBox.Show<span class="token punctuation">(</span><span class="token string">"添加成功"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token punctuation">}</span>
        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 刷新租车集合
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        public void addTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>

            listHire.Items.Clear<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>TrafficInfo t <span class="token keyword">in</span> m_RM.DicMyTraffics.Values<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                ListViewItem lv <span class="token operator">=</span> new ListViewItem<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//显示项
                lv.Text <span class="token operator">=</span> t.Number<span class="token punctuation">;</span>
                ListViewItem.ListViewSubItem<span class="token punctuation">[</span><span class="token punctuation">]</span> lvs<span class="token punctuation">;</span>
                lvs <span class="token operator">=</span> new ListViewItem.ListViewSubItem<span class="token punctuation">[</span>5<span class="token punctuation">]</span>//显示子项
                     <span class="token punctuation">{</span> 
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>
                     <span class="token punctuation">}</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Name<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>1<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Color<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>2<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Time.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>3<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Money.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>4<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Load<span class="token punctuation">;</span>

                listHire.Items.Add<span class="token punctuation">(</span>lv<span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.SubItems.AddRange<span class="token punctuation">(</span>lvs<span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.Tag <span class="token operator">=</span> t<span class="token punctuation">;</span>
                lv.ImageKey <span class="token operator">=</span> <span class="token string">"1.png"</span><span class="token punctuation">;</span>

            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 刷新还车集合
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        public void backTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>

            listback.Items.Clear<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>TrafficInfo t <span class="token keyword">in</span> m_RM.DicRenteds.Values<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                ListViewItem lv <span class="token operator">=</span> new ListViewItem<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//显示项
                lv.Text <span class="token operator">=</span> t.Number<span class="token punctuation">;</span>
                ListViewItem.ListViewSubItem<span class="token punctuation">[</span><span class="token punctuation">]</span> lvs<span class="token punctuation">;</span>
                lvs <span class="token operator">=</span> new ListViewItem.ListViewSubItem<span class="token punctuation">[</span>7<span class="token punctuation">]</span>//显示子项
                     <span class="token punctuation">{</span> 
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>
                     <span class="token punctuation">}</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Name<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>1<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Color<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>2<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Time.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>3<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Money.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>4<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Load<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>5<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.tenement<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>6<span class="token punctuation">]</span>.Text <span class="token operator">=</span> dateTime.Text<span class="token punctuation">;</span>
                lv.SubItems.AddRange<span class="token punctuation">(</span>lvs<span class="token punctuation">)</span><span class="token punctuation">;</span>
                listback.Items.Add<span class="token punctuation">(</span>lv<span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.Tag <span class="token operator">=</span> t<span class="token punctuation">;</span>
                lv.ImageKey <span class="token operator">=</span> <span class="token string">"1.png"</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

        <span class="token comment" spellcheck="true">#region 选择车的Load判断</span>
        private void rdoCar_CheckedChanged<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>rdoCar.Checked <span class="token operator">==</span> true<span class="token punctuation">)</span>//选上
            <span class="token punctuation">{</span>
                this.txtLoad.Text <span class="token operator">=</span> <span class="token string">"--无--"</span><span class="token punctuation">;</span>
                this.txtLoad.ReadOnly <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
                this.txtLoad.Cursor <span class="token operator">=</span> Cursors.No<span class="token punctuation">;</span>


            <span class="token punctuation">}</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>rdoTruck.Checked <span class="token operator">==</span> true<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                this.txtLoad.Text <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
                this.txtLoad.ReadOnly <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
                this.txtLoad.Cursor <span class="token operator">=</span> Cursors.IBeam<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

        <span class="token punctuation">}</span> 
        <span class="token comment" spellcheck="true">#endregion</span>

        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 标题
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"sender"</span><span class="token operator">></span><span class="token operator">&lt;</span>/param<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"e"</span><span class="token operator">></span><span class="token operator">&lt;</span>/param<span class="token operator">></span>
        private void Form1_Load<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            dateTime.Text <span class="token operator">=</span> DateTime.Now.ToString<span class="token punctuation">(</span><span class="token string">"yyyy/MM/dd"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment" spellcheck="true">#region 租车头部显示  </span>
            ColumnHeader colNumeber, colName, colColor, colTime, colMoney, colLoad<span class="token punctuation">;</span>
            ColumnHeader<span class="token punctuation">[</span><span class="token punctuation">]</span> chArr <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">[</span>6<span class="token punctuation">]</span>
            <span class="token punctuation">{</span>
                 colNumeber <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colName <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colColor <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colTime <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colMoney <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colLoad <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">}</span><span class="token punctuation">;</span>
            colTime.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> colLoad.Width <span class="token operator">=</span> 60<span class="token punctuation">;</span> colNumeber.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> colName.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车牌号"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>1<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车名"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>2<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车颜色"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>3<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"使用时间"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>4<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"租金"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>5<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"载重量"</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>ColumnHeader ch <span class="token keyword">in</span> chArr<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                ch.TextAlign <span class="token operator">=</span> HorizontalAlignment.Center<span class="token punctuation">;</span>//居中
            <span class="token punctuation">}</span>
            listHire.Columns.AddRange<span class="token punctuation">(</span>chArr<span class="token punctuation">)</span><span class="token punctuation">;</span> 
            <span class="token comment" spellcheck="true">#endregion</span>

            <span class="token comment" spellcheck="true">#region 还车头部显示</span>
            ColumnHeader colBNumeber, colBName, colBColor, colBTime, colBMoney, colBLoad, colBtenant, coldateTime<span class="token punctuation">;</span>
            ColumnHeader<span class="token punctuation">[</span><span class="token punctuation">]</span> chBack <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">[</span>8<span class="token punctuation">]</span>
            <span class="token punctuation">{</span>
                 colBNumeber <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBName <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBColor <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBTime <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBMoney <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBLoad <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBtenant <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 coldateTime <span class="token operator">=</span>new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">}</span><span class="token punctuation">;</span>
            colBTime.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> colBLoad.Width <span class="token operator">=</span> 60<span class="token punctuation">;</span> colBNumeber.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> colBName.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> coldateTime.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车牌号"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>1<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车名"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>2<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车颜色"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>3<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"使用时间"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>4<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"租金"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>5<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"载重量"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>6<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"租户"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>7<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"出租时间"</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>ColumnHeader ch <span class="token keyword">in</span> chBack<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                ch.TextAlign <span class="token operator">=</span> HorizontalAlignment.Center<span class="token punctuation">;</span>//居中
            <span class="token punctuation">}</span>
            listback.Columns.AddRange<span class="token punctuation">(</span>chBack<span class="token punctuation">)</span><span class="token punctuation">;</span> 
            <span class="token comment" spellcheck="true">#endregion</span>

            <span class="token comment" spellcheck="true">#region 反序列化</span>
            FileStream fs <span class="token operator">=</span> new FileStream<span class="token punctuation">(</span><span class="token string">"Students.bin"</span>, FileMode.OpenOrCreate<span class="token punctuation">)</span><span class="token punctuation">;</span>
            BinaryFormatter bf <span class="token operator">=</span> new BinaryFormatter<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>fs.Length <span class="token operator">></span> 0<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                m_RM <span class="token operator">=</span> bf.Deserialize<span class="token punctuation">(</span>fs<span class="token punctuation">)</span> as XRentManager<span class="token punctuation">;</span>//反序列化
            <span class="token punctuation">}</span>
            bf <span class="token operator">=</span> null<span class="token punctuation">;</span>
            fs.Close<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            fs.Dispose<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
            <span class="token comment" spellcheck="true">#endregion</span>
            backTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//还车
            addTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//租车

        <span class="token punctuation">}</span>

        //出租
        private void btnHire_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>


            <span class="token keyword">if</span> <span class="token punctuation">(</span>listHire.SelectedItems.Count <span class="token operator">==</span> 0<span class="token punctuation">)</span> <span class="token keyword">return</span><span class="token punctuation">;</span>//判断下
            TrafficInfo listback <span class="token operator">=</span> listHire.SelectedItems<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Tag as TrafficInfo<span class="token punctuation">;</span>
            listback.tenement <span class="token operator">=</span> txtUser.Text<span class="token punctuation">;</span>
            listback.datatime <span class="token operator">=</span> dateTime.Text<span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>txtUser.Text <span class="token operator">==</span> <span class="token string">""</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span> MessageBox.Show<span class="token punctuation">(</span><span class="token string">"情输入租户姓名"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> txtUser.Focus<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
            m_RM.Rent<span class="token punctuation">(</span>listback<span class="token punctuation">)</span><span class="token punctuation">;</span>
            MessageBox.Show<span class="token punctuation">(</span><span class="token string">"出租成功"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            this.tabControl1.SelectedTab <span class="token operator">=</span> tpReturn<span class="token punctuation">;</span>
            backTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//还车
            addTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//租车
        <span class="token punctuation">}</span>
        //金额简单结算
        private void btnBalance_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>txtDays.Text <span class="token operator">==</span> <span class="token string">""</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span> MessageBox.Show<span class="token punctuation">(</span><span class="token string">"情输入租用时间"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> txtDays.Focus<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
            TrafficInfo list <span class="token operator">=</span> listback.SelectedItems<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Tag as TrafficInfo<span class="token punctuation">;</span>
            int days <span class="token operator">=</span> int.Parse<span class="token punctuation">(</span>txtDays.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            double prise <span class="token operator">=</span> list.Money<span class="token punctuation">;</span>
            double total <span class="token operator">=</span> days * prise<span class="token punctuation">;</span>
            MessageBox.Show<span class="token punctuation">(</span><span class="token string">"总计费用"</span>+total<span class="token punctuation">)</span><span class="token punctuation">;</span>
            TrafficInfo listHire <span class="token operator">=</span> listback.SelectedItems<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Tag as TrafficInfo<span class="token punctuation">;</span>
            m_RM.InputLibry<span class="token punctuation">(</span>listHire<span class="token punctuation">)</span><span class="token punctuation">;</span>//
            MessageBox.Show<span class="token punctuation">(</span><span class="token string">"已还车"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            this.tabControl1.SelectedTab <span class="token operator">=</span> tpRent<span class="token punctuation">;</span>//转向
            backTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//还车
            addTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//租车

        <span class="token punctuation">}</span>

        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 序列化存进2进制流
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"fileName"</span><span class="token operator">></span>路径<span class="token operator">&lt;</span>/param<span class="token operator">></span>
        private void LoadDate<span class="token punctuation">(</span>string fileName<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token comment" spellcheck="true">#region 序列化</span>
            FileStream fs <span class="token operator">=</span> new FileStream<span class="token punctuation">(</span>fileName, FileMode.OpenOrCreate<span class="token punctuation">)</span><span class="token punctuation">;</span>
            BinaryFormatter bf <span class="token operator">=</span> new BinaryFormatter<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//创建序列化
            bf.Serialize<span class="token punctuation">(</span>fs, m_RM<span class="token punctuation">)</span><span class="token punctuation">;</span>//保存
            bf <span class="token operator">=</span> null<span class="token punctuation">;</span>
            fs.Close<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            fs.Dispose<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
            <span class="token comment" spellcheck="true">#endregion</span>
        <span class="token punctuation">}</span>
        private void Form1_FormClosed<span class="token punctuation">(</span>object sender, FormClosedEventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            this.LoadDate<span class="token punctuation">(</span><span class="token string">"Students.bin"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>


        <span class="token comment" spellcheck="true">#region 视图</span>
        private void MenuLarge_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            listHire.View <span class="token operator">=</span> View.LargeIcon<span class="token punctuation">;</span>
            listHire.View <span class="token operator">=</span> View.LargeIcon<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        private void MenuSmall_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            listHire.View <span class="token operator">=</span> View.SmallIcon<span class="token punctuation">;</span>
            listHire.View <span class="token operator">=</span> View.SmallIcon<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        private void MenuPart_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            listHire.View <span class="token operator">=</span> View.Details<span class="token punctuation">;</span>
            listHire.View <span class="token operator">=</span> View.Details<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>  
        <span class="token comment" spellcheck="true">#endregion</span>

        private void btnExit_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            this.Close<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 删
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"sender"</span><span class="token operator">></span><span class="token operator">&lt;</span>/param<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"e"</span><span class="token operator">></span><span class="token operator">&lt;</span>/param<span class="token operator">></span>
        private void btnDelete_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            //TrafficInfo delect <span class="token operator">=</span> listHire.SelectedItems<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Tag as TrafficInfo<span class="token punctuation">;</span>
            //m_RM.DicMyTraffics.Remove<span class="token punctuation">(</span>delect.Name<span class="token punctuation">)</span><span class="token punctuation">;</span>
            int count <span class="token operator">=</span> listHire.SelectedItems.Count<span class="token punctuation">;</span>
            string key <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span>int i <span class="token operator">=</span> 0<span class="token punctuation">;</span> i <span class="token operator">&lt;</span> count<span class="token punctuation">;</span> i++<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                key <span class="token operator">=</span> listHire.SelectedItems<span class="token punctuation">[</span>i<span class="token punctuation">]</span>.Text<span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>m_RM.DicMyTraffics.ContainsKey<span class="token punctuation">(</span>key<span class="token punctuation">))</span>
                <span class="token punctuation">{</span>
                    m_RM.DicMyTraffics.Remove<span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>

            <span class="token punctuation">}</span>
            MessageBox.Show<span class="token punctuation">(</span><span class="token string">"删除成功"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            addTraffic<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//租车
        <span class="token punctuation">}</span>

        private void dateTime_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>

        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h2 id="数据存到sqlserver的版本核心代码"><a href="#数据存到sqlserver的版本核心代码" class="headerlink" title="数据存到sqlserver的版本核心代码"></a>数据存到sqlserver的版本核心代码</h2><pre class=" language-bash"><code class="language-bash">using System<span class="token punctuation">;</span>
using System.Collections.Generic<span class="token punctuation">;</span>
using System.ComponentModel<span class="token punctuation">;</span>
using System.Data<span class="token punctuation">;</span>
using System.Drawing<span class="token punctuation">;</span>
using System.Linq<span class="token punctuation">;</span>
using System.Text<span class="token punctuation">;</span>
using System.Windows.Forms<span class="token punctuation">;</span>
using System.Collections<span class="token punctuation">;</span>
using System.IO<span class="token punctuation">;</span>
using System.Runtime.Serialization.Formatters.Binary<span class="token punctuation">;</span>
using Car.DAL<span class="token punctuation">;</span>
using Car.BLL<span class="token punctuation">;</span>
using Car.Model<span class="token punctuation">;</span>
namespace Car
<span class="token punctuation">{</span>
    public partial class Form1 <span class="token keyword">:</span> Form
    <span class="token punctuation">{</span>

        TrafficInfo tNew<span class="token punctuation">;</span>//父类
        XRentManager m_RM<span class="token punctuation">;</span>//管理类
        public Form1<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            InitializeComponent<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        private void btnAdd_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            TraMessage<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//入库信息

        <span class="token punctuation">}</span>
        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 入库信息
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        public void TraMessage<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            string <span class="token function">type</span> <span class="token operator">=</span> rdoTruck.Checked <span class="token operator">==</span> <span class="token boolean">true</span> ? <span class="token string">"Truck"</span> <span class="token keyword">:</span> <span class="token string">"Car"</span><span class="token punctuation">;</span>
            tNew <span class="token operator">=</span> TrafficFactoruy.CreatNewTraffic<span class="token punctuation">(</span>type<span class="token punctuation">)</span><span class="token punctuation">;</span> //工厂模式
            <span class="token comment" spellcheck="true">#region 为空判断</span>

            Dictionary<span class="token operator">&lt;</span>string, string<span class="token operator">></span> dicTracffic <span class="token operator">=</span> new Dictionary<span class="token operator">&lt;</span>string, string<span class="token operator">></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"车牌号"</span>, txtNumber.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"车名"</span>, txtName.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"车颜色"</span>, cbColor.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"使用时间"</span>, txtTime.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"租金"</span>, txtMoney.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            dicTracffic.Add<span class="token punctuation">(</span><span class="token string">"载重量"</span>, txtLoad.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>string str <span class="token keyword">in</span> dicTracffic.Keys<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>dicTracffic<span class="token punctuation">[</span>str<span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">""</span><span class="token punctuation">)</span> //str就是K,dicTracffic<span class="token punctuation">[</span>str<span class="token punctuation">]</span>就是值
                <span class="token punctuation">{</span>
                    MessageBox.Show<span class="token punctuation">(</span>string.Format<span class="token punctuation">(</span><span class="token string">"请输入{0}"</span>, str<span class="token punctuation">))</span><span class="token punctuation">;</span>

                    <span class="token keyword">return</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
            <span class="token comment" spellcheck="true">#endregion</span>
            <span class="token comment" spellcheck="true">#region 非工厂模式创立对象</span>
            //if <span class="token punctuation">(</span>rdoCar.Checked <span class="token operator">==</span> true<span class="token punctuation">)</span>
            //<span class="token punctuation">{</span>
            //    tNew <span class="token operator">=</span> new Xcar<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//创立对象
            //<span class="token punctuation">}</span>
            //if <span class="token punctuation">(</span>rdoTruck.Checked <span class="token operator">==</span> true<span class="token punctuation">)</span>
            //<span class="token punctuation">{</span>
            //    tNew <span class="token operator">=</span> new XTruck<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            //<span class="token punctuation">}</span> 
            <span class="token comment" spellcheck="true">#endregion</span>
            tNew.Number <span class="token operator">=</span> txtNumber.Text<span class="token punctuation">;</span>//车牌号码
            tNew.Name <span class="token operator">=</span> txtName.Text<span class="token punctuation">;</span>//车名
            tNew.Color <span class="token operator">=</span> cbColor.Text<span class="token punctuation">;</span>//车颜色
            tNew.Time <span class="token operator">=</span> Convert.ToInt32<span class="token punctuation">(</span>txtTime.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>//使用时间
            tNew.Money <span class="token operator">=</span> int.Parse<span class="token punctuation">(</span>txtMoney.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>//租金
            tNew.Load <span class="token operator">=</span> txtLoad.Text<span class="token punctuation">;</span>//载重
            <span class="token comment" spellcheck="true">#region 新增数据</span>
            TrafficBLL insertBLL <span class="token operator">=</span> new TrafficBLL<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>tNew is Xcar<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                insertBLL.AddNewTrafficToDbase<span class="token punctuation">(</span>tNew, 1<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">else</span>
            <span class="token punctuation">{</span>
                insertBLL.AddNewTrafficToDbase<span class="token punctuation">(</span>tNew, 2<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            MessageBox.Show<span class="token punctuation">(</span><span class="token string">"增加成功"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment" spellcheck="true">#endregion</span>
            addMyTrafficShow<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//查到数据然后刷新
            this.tabControl1.SelectedTab <span class="token operator">=</span> tpRent<span class="token punctuation">;</span>//跳过去
        <span class="token punctuation">}</span>
        <span class="token comment" spellcheck="true">#region 选择车的Load判断</span>
        private void rdoCar_CheckedChanged<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>rdoCar.Checked <span class="token operator">==</span> true<span class="token punctuation">)</span>//选上
            <span class="token punctuation">{</span>
                this.txtLoad.Text <span class="token operator">=</span> <span class="token string">"--无--"</span><span class="token punctuation">;</span>
                this.txtLoad.ReadOnly <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
                this.txtLoad.Cursor <span class="token operator">=</span> Cursors.No<span class="token punctuation">;</span>


            <span class="token punctuation">}</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>rdoTruck.Checked <span class="token operator">==</span> true<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                this.txtLoad.Text <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
                this.txtLoad.ReadOnly <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
                this.txtLoad.Cursor <span class="token operator">=</span> Cursors.IBeam<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

        <span class="token punctuation">}</span> 
        <span class="token comment" spellcheck="true">#endregion</span>

        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 标题
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"sender"</span><span class="token operator">></span><span class="token operator">&lt;</span>/param<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"e"</span><span class="token operator">></span><span class="token operator">&lt;</span>/param<span class="token operator">></span>
        private void Form1_Load<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            //dateTime.Text <span class="token operator">=</span> DateTime.Now.ToString<span class="token punctuation">(</span><span class="token string">"yyyy/MM/dd"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            dateTime.Text <span class="token operator">=</span> DateTime.Now.ToString<span class="token punctuation">(</span><span class="token string">"F"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//拿到时间所有
            <span class="token comment" spellcheck="true">#region 租车头部显示  </span>
            ColumnHeader colNumeber, colName, colColor, colTime, colMoney, colLoad<span class="token punctuation">;</span>
            ColumnHeader<span class="token punctuation">[</span><span class="token punctuation">]</span> chArr <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">[</span>6<span class="token punctuation">]</span>
            <span class="token punctuation">{</span>
                 colNumeber <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colName <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colColor <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colTime <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colMoney <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colLoad <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>    
            <span class="token punctuation">}</span><span class="token punctuation">;</span>
            colTime.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> colLoad.Width <span class="token operator">=</span> 60<span class="token punctuation">;</span> colNumeber.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> colName.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车牌号"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>1<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车名"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>2<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车颜色"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>3<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"使用时间"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>4<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"租金"</span><span class="token punctuation">;</span>
            chArr<span class="token punctuation">[</span>5<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"载重量"</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>ColumnHeader ch <span class="token keyword">in</span> chArr<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                ch.TextAlign <span class="token operator">=</span> HorizontalAlignment.Center<span class="token punctuation">;</span>//居中
            <span class="token punctuation">}</span>
            listHire.Columns.AddRange<span class="token punctuation">(</span>chArr<span class="token punctuation">)</span><span class="token punctuation">;</span> 
            <span class="token comment" spellcheck="true">#endregion</span>
            <span class="token comment" spellcheck="true">#region 还车头部显示</span>
            ColumnHeader colBNumeber, colBName, colBColor, colBTime, colBMoney, colBLoad, colBtenant, coldateTime<span class="token punctuation">;</span>
            ColumnHeader<span class="token punctuation">[</span><span class="token punctuation">]</span> chBack <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">[</span>8<span class="token punctuation">]</span>
            <span class="token punctuation">{</span>
                 colBNumeber <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBName <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBColor <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBTime <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBMoney <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBLoad <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 colBtenant <span class="token operator">=</span> new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                 coldateTime <span class="token operator">=</span>new ColumnHeader<span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">}</span><span class="token punctuation">;</span>
            colBTime.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> colBLoad.Width <span class="token operator">=</span> 60<span class="token punctuation">;</span> colBNumeber.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> colBName.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span> coldateTime.Width <span class="token operator">=</span> 100<span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车牌号"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>1<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车名"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>2<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"车颜色"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>3<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"使用时间"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>4<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"租金"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>5<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"载重量"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>6<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"租户"</span><span class="token punctuation">;</span>
            chBack<span class="token punctuation">[</span>7<span class="token punctuation">]</span>.Text <span class="token operator">=</span> <span class="token string">"出租时间"</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>ColumnHeader ch <span class="token keyword">in</span> chBack<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                ch.TextAlign <span class="token operator">=</span> HorizontalAlignment.Center<span class="token punctuation">;</span>//居中
            <span class="token punctuation">}</span>
            listback.Columns.AddRange<span class="token punctuation">(</span>chBack<span class="token punctuation">)</span><span class="token punctuation">;</span> 
            <span class="token comment" spellcheck="true">#endregion</span>
            addMyTrafficShow<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
            addMyRentShow<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 加到租车listHire集合然后显示出来/刷新租车表
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        public void addMyTrafficShow<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            listHire.Items.Clear<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
             m_RM <span class="token operator">=</span> new XRentManager<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//实例化一个管理类对象
             TrafficBLL showBLL <span class="token operator">=</span> new TrafficBLL<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
             showBLL.showTraffic<span class="token punctuation">(</span>tNew, m_RM<span class="token punctuation">)</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>TrafficInfo t <span class="token keyword">in</span> m_RM.DicMyTraffics.Values<span class="token punctuation">)</span>//显示子项
            <span class="token punctuation">{</span>
                ListViewItem lv <span class="token operator">=</span> new ListViewItem<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.Text <span class="token operator">=</span> t.Number<span class="token punctuation">;</span>
                ListViewItem.ListViewSubItem<span class="token punctuation">[</span><span class="token punctuation">]</span> lvs<span class="token punctuation">;</span>
                lvs <span class="token operator">=</span> new ListViewItem.ListViewSubItem<span class="token punctuation">[</span>5<span class="token punctuation">]</span>
                     <span class="token punctuation">{</span> 
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>
                     <span class="token punctuation">}</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Name<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>1<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Color<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>2<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Time.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>3<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Money.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>4<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Load<span class="token punctuation">;</span>
                lv.Tag <span class="token operator">=</span> t<span class="token punctuation">;</span>
                listHire.Items.Add<span class="token punctuation">(</span>lv<span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.SubItems.AddRange<span class="token punctuation">(</span>lvs<span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.ImageKey <span class="token operator">=</span> <span class="token string">"1.png"</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 加到还车车<span class="token punctuation">(</span>listback<span class="token punctuation">)</span>集合然后显示出来
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        public void addMyRentShow<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            listback.Items.Clear<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            m_RM <span class="token operator">=</span> new XRentManager<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>//实例化一个管理类对象
            TrafficBLL showBLL <span class="token operator">=</span> new TrafficBLL<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            showBLL.showRent<span class="token punctuation">(</span>tNew, m_RM<span class="token punctuation">)</span><span class="token punctuation">;</span>
            foreach <span class="token punctuation">(</span>TrafficInfo t <span class="token keyword">in</span> m_RM.DicRenteds.Values<span class="token punctuation">)</span>//显示子项
            <span class="token punctuation">{</span>
                ListViewItem lv <span class="token operator">=</span> new ListViewItem<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.Text <span class="token operator">=</span> t.Number<span class="token punctuation">;</span>
                ListViewItem.ListViewSubItem<span class="token punctuation">[</span><span class="token punctuation">]</span> lvs<span class="token punctuation">;</span>
                lvs <span class="token operator">=</span> new ListViewItem.ListViewSubItem<span class="token punctuation">[</span>7<span class="token punctuation">]</span>
                     <span class="token punctuation">{</span> 
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>,
                      new ListViewItem.ListViewSubItem<span class="token punctuation">(</span><span class="token punctuation">)</span>
                     <span class="token punctuation">}</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Name<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>1<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Color<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>2<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Time.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>3<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Money.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>4<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.Load<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>5<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.RentName<span class="token punctuation">;</span>
                lvs<span class="token punctuation">[</span>6<span class="token punctuation">]</span>.Text <span class="token operator">=</span> t.RentDate.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.Tag <span class="token operator">=</span> t<span class="token punctuation">;</span>
                listback.Items.Add<span class="token punctuation">(</span>lv<span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.SubItems.AddRange<span class="token punctuation">(</span>lvs<span class="token punctuation">)</span><span class="token punctuation">;</span>
                lv.ImageKey <span class="token operator">=</span> <span class="token string">"1.png"</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        //出租
        private void btnHire_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>listHire.SelectedItems.Count <span class="token operator">==</span> 0<span class="token punctuation">)</span> <span class="token keyword">return</span><span class="token punctuation">;</span>//判断下
            TrafficInfo RentTraffic <span class="token operator">=</span> listHire.SelectedItems<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Tag as TrafficInfo<span class="token punctuation">;</span>
            RentTraffic.RentName <span class="token operator">=</span> txtUser.Text<span class="token punctuation">;</span>
            RentTraffic.RentDate <span class="token operator">=</span>Convert.ToDateTime<span class="token punctuation">(</span>dateTime.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
            RentTraffic.RentNumber <span class="token operator">=</span> RentTraffic.Number<span class="token punctuation">;</span>
            RentTraffic.RentManID <span class="token operator">=</span> txtRentManID.Text<span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>txtUser.Text <span class="token operator">==</span> <span class="token string">""</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span> MessageBox.Show<span class="token punctuation">(</span><span class="token string">"情输入租户姓名"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> txtUser.Focus<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>txtRentManID.Text <span class="token operator">==</span> <span class="token string">""</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span> MessageBox.Show<span class="token punctuation">(</span><span class="token string">"情输入租户证件号码"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> txtUser.Focus<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
            TrafficBLL BLL <span class="token operator">=</span> new TrafficBLL<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            BLL.addRent<span class="token punctuation">(</span>RentTraffic<span class="token punctuation">)</span><span class="token punctuation">;</span>

            MessageBox.Show<span class="token punctuation">(</span><span class="token string">"出租成功"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            this.tabControl1.SelectedTab <span class="token operator">=</span> tpReturn<span class="token punctuation">;</span>
            addMyRentShow<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            addMyTrafficShow<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        //结算,还车
        private void btnBalance_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            TrafficInfo listHire <span class="token operator">=</span> listback.SelectedItems<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Tag as TrafficInfo<span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>listHire <span class="token operator">!=</span>null<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                listHire.ReturnDate <span class="token operator">=</span> Convert.ToDateTime<span class="token punctuation">(</span>dateTime.Text<span class="token punctuation">)</span><span class="token punctuation">;</span>
                listHire.RentNumber <span class="token operator">=</span> listHire.Number<span class="token punctuation">;</span>
                TrafficBLL balance <span class="token operator">=</span> new TrafficBLL<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                balance.addlistHire<span class="token punctuation">(</span>listHire<span class="token punctuation">)</span><span class="token punctuation">;</span>
                MessageBox.Show<span class="token punctuation">(</span><span class="token string">"已还车"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                this.tabControl1.SelectedTab <span class="token operator">=</span> tpRent<span class="token punctuation">;</span>//转向
                addMyRentShow<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                addMyTrafficShow<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>   
        <span class="token punctuation">}</span>

        <span class="token comment" spellcheck="true">#region 视图</span>
        private void MenuLarge_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            listHire.View <span class="token operator">=</span> View.LargeIcon<span class="token punctuation">;</span>
            listHire.View <span class="token operator">=</span> View.LargeIcon<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        private void MenuSmall_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            listHire.View <span class="token operator">=</span> View.SmallIcon<span class="token punctuation">;</span>
            listHire.View <span class="token operator">=</span> View.SmallIcon<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        private void MenuPart_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            listHire.View <span class="token operator">=</span> View.Details<span class="token punctuation">;</span>
            listHire.View <span class="token operator">=</span> View.Details<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>  
        <span class="token comment" spellcheck="true">#endregion</span>

        private void btnExit_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            this.Close<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        /// <span class="token operator">&lt;</span>summary<span class="token operator">></span>
        /// 删
        /// <span class="token operator">&lt;</span>/summary<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"sender"</span><span class="token operator">></span><span class="token operator">&lt;</span>/param<span class="token operator">></span>
        /// <span class="token operator">&lt;</span>param name<span class="token operator">=</span><span class="token string">"e"</span><span class="token operator">></span><span class="token operator">&lt;</span>/param<span class="token operator">></span>
        private void btnDelete_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
          TrafficInfo delete<span class="token operator">=</span>listHire.SelectedItems<span class="token punctuation">[</span>0<span class="token punctuation">]</span>.Tag as TrafficInfo<span class="token punctuation">;</span>
          TrafficBLL dBLL <span class="token operator">=</span> new TrafficBLL<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          bool res<span class="token operator">=</span>  dBLL.deleteTraffic<span class="token punctuation">(</span>delete<span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token keyword">if</span> <span class="token punctuation">(</span>res<span class="token punctuation">)</span>
          <span class="token punctuation">{</span>
              MessageBox.Show<span class="token punctuation">(</span><span class="token string">"删除成功"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
              addMyTrafficShow<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span>
          <span class="token keyword">else</span> 
          <span class="token punctuation">{</span>
              MessageBox.Show<span class="token punctuation">(</span><span class="token string">"请选中一项"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span>       
        <span class="token punctuation">}</span>

        private void btnAccount_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            FormAccount Account <span class="token operator">=</span> new FormAccount<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            Account.ShowDialog<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>github代码下载：<a href="https://github.com/zy20081/practice.git" target="_blank" rel="noopener">https://github.com/zy20081/practice.git</a></p>

            </div>
            <hr>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff;
        background-color: #22AB38;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff;
        background-color: #019FE8;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a class="reward-link btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs">
                        <li class="tab wechat-tab waves-effect waves-light"><a class="active" href="#wechat">微信</a></li>
                        <li class="tab alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                    </ul>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('#reward .reward-link').on('click', function () {
            $('#rewardModal').openModal();
        });

        $('#rewardModal .close').on('click', function () {
            $('#rewardModal').closeModal();
        });
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            <div class="reprint">
                <p>
                    <span class="reprint-tip">转载请注明: </span>
                    <a href="https://zy20081.github.io" class="b-link-green">Zhou•Yong</a>
                    <i class="fa fa-angle-right fa-lg fa-fw text-color"></i>
                    <a href="/2019/01/11/qi-che-zu-ren-guan-li-xi-tong/" class="b-link-green">汽车租赁管理系统</a>
                </p>
            </div>
        </div>
    </div>

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">上一篇</div>
            <div class="card">
                <a href="/2019/01/12/while-for-if-ying-yong/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/3.jpg" class="responsive-img" alt="while/for/if 应用">
                        
                        <span class="card-title">while/for/if 应用</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">说明1-100while求和 static void Main(string[] args)
        {
            Sum();
        }
        static void Sum()
        </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2019-01-12
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/C/" class="post-category" target="_blank">
                                    C#
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/C-基础知识/" target="_blank">
                        <span class="chip bg-color">C# 基础知识</span>
                    </a>
                    
                    <a href="/tags/C/" target="_blank">
                        <span class="chip bg-color">C#</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">下一篇</div>
            <div class="card">
                <a href="/2019/01/11/xiang-ce/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/20.jpg" class="responsive-img" alt="相册">
                        
                        <span class="card-title">相册</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">
相册学C#的时候，第一个作业练习demo
主要代码using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data</div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2019-01-11
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/ASP-NET/" class="post-category" target="_blank">
                                    ASP.NET
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/ASP-NET/" target="_blank">
                        <span class="chip bg-color">ASP.NET</span>
                    </a>
                    
                    <a href="/tags/C-Demo/" target="_blank">
                        <span class="chip bg-color">C# Demo</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>


    </div>
    <div class="col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title">目录</div>
            <div id="toc-content">

            </div>
        </div>
    </div>
</div>

<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });
    });
</script>
    

</main>


<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            本站由ZhouYong 技术分享，心得分享.
        </div>
        <div class="col s12 m4 l4 social-link"><a href="#!" class="tooltipped" data-tooltip="邮件联系我: zy20081@126.com" data-position="top" data-delay="50">
    <i class="fa fa-envelope-open"></i>
</a>
<a href="#!" class="tooltipped" data-tooltip="QQ联系我: 314153271" data-position="top" data-delay="50">
    <i class="fa fa-qq"></i>
</a>

<a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
    <i class="fa fa-rss"></i>
</a>
</div>
    </div>
</footer>

<div class="progress-bar"></div>


<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title">搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字" class="search-input" autofocus>
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/js/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>

<script src="/libs/others/clicklove.js"></script>

<script src="/js/matery.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->


</body>
</html>